package com.ruoyi.web.controller.system;

import java.util.List;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysFondsDept;
import com.ruoyi.system.service.ISysFondsDeptService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 机构和全宗关联Controller
 * 
 * @author ruoyi
 * @date 2022-02-12
 */
@RestController
@RequestMapping("/system/fondsdept")
public class SysFondsDeptController extends BaseController
{
    @Autowired
    private ISysFondsDeptService sysFondsDeptService;

    /**
     * 查询机构和全宗关联列表
     */
    @PreAuthorize("@ss.hasPermi('system:dept:list')")
    @ApiOperation("查询机构和全宗关联列表")
    @GetMapping("/list")
    public TableDataInfo list(SysFondsDept sysFondsDept)
    {
        startPage();
        List<SysFondsDept> list = sysFondsDeptService.selectSysFondsDeptList(sysFondsDept);
        return getDataTable(list);
    }

    /**
     * 导出机构和全宗关联列表
     */
    @PreAuthorize("@ss.hasPermi('system:dept:export')")
    @Log(title = "机构和全宗关联", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysFondsDept sysFondsDept)
    {
        List<SysFondsDept> list = sysFondsDeptService.selectSysFondsDeptList(sysFondsDept);
        ExcelUtil<SysFondsDept> util = new ExcelUtil<SysFondsDept>(SysFondsDept.class);
        return util.exportExcel(list, "dept");
    }

    /**
     * 获取机构和全宗关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dept:query')")
    @ApiOperation("获取机构和全宗关联详细信息")
    @ApiImplicitParam(name = "recNo", value = "机构和全宗关联表编号", required = true, dataType = "String", paramType = "传机构和全宗关联表编号")
    @GetMapping(value = "/{recNo}")
    public AjaxResult getInfo(@PathVariable("recNo") String recNo)
    {
        return AjaxResult.success(sysFondsDeptService.selectSysFondsDeptById(recNo));
    }

    /**
     * 新增机构和全宗关联
     */
    @PreAuthorize("@ss.hasPermi('system:dept:add')")
    @Log(title = "机构和全宗关联", businessType = BusinessType.INSERT)
    @ApiOperation("新增机构和全宗关联")
    @ApiImplicitParam(name = "sysFondsDept", value = "新增机构和全宗关联对象", required = true, dataType = "SysFondsDept", paramType = "传新增机构和全宗关联对象")
    @PostMapping
    public AjaxResult add(@RequestBody SysFondsDept sysFondsDept)
    {
        return toAjax(sysFondsDeptService.insertSysFondsDept(sysFondsDept));
    }

    /**
     * 修改机构和全宗关联
     */
    @PreAuthorize("@ss.hasPermi('system:dept:edit')")
    @Log(title = "机构和全宗关联", businessType = BusinessType.UPDATE)
    @ApiOperation("修改机构和全宗关联")
    @ApiImplicitParam(name = "sysFondsDept", value = "新增机构和全宗关联对象", required = true, dataType = "SysFondsDept", paramType = "传新增机构和全宗关联对象")
    @PutMapping
    public AjaxResult edit(@RequestBody SysFondsDept sysFondsDept)
    {
        return toAjax(sysFondsDeptService.updateSysFondsDept(sysFondsDept));
    }

    /**
     * 删除机构和全宗关联
     */
    @PreAuthorize("@ss.hasPermi('system:dept:remove')")
    @Log(title = "机构和全宗关联", businessType = BusinessType.DELETE)
    @ApiOperation("删除机构和全宗关联")
    @ApiImplicitParam(name = "recNos", value = "机构和全宗关联编号数组", required = true, dataType = "String[]", paramType = "传机构和全宗关联编号数组")
    @DeleteMapping("/{recNos}")
    public AjaxResult remove(@PathVariable String[] recNos)
    {
        return toAjax(sysFondsDeptService.deleteSysFondsDeptByIds(recNos));
    }
}
